// 退格字符


function processBackspaces(str) {
  const result = [];
  for (let char of str) {
    if (char === '#') {
      if (result.length > 0) {
        result.pop();
      }
    } else {
      result.push(char);
    }
  }
  return result.join('');
}

// 示例使用
const input = "abc#d##c";
const output = processBackspaces(input);
console.log(output);
